package com.jic.market.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.entity.DiscountPromotionDetail;
import com.jic.market.mapper.DiscountPromotionDetailMapper;
import com.jic.market.service.DiscountPromotionDetailService;
import com.jic.order.request.OrderNoPage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DiscountPromotionDetailServiceImpl implements DiscountPromotionDetailService {

    @Resource
    private DiscountPromotionDetailMapper discountPromotionDetailMapper;
    @Resource
    private DiscountPromotionDetailService service;
    @Override
    public long insert(DiscountPromotionDetail discountPromotionDetail) {
        return discountPromotionDetailMapper.insert(discountPromotionDetail);
    }

    @Override
    public long delete(Long id) {
        return discountPromotionDetailMapper.delete(id);
    }

    @Override
    public long update(DiscountPromotionDetail discountPromotionDetail) {
        return discountPromotionDetailMapper.update(discountPromotionDetail);
    }

    @Override
    public DiscountPromotionDetail queryByPrimaryKey(Long id) {
        return discountPromotionDetailMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<DiscountPromotionDetail> query(DiscountPromotionDetail discountPromotionDetail) {
        return discountPromotionDetailMapper.query(discountPromotionDetail);
    }

    @Override
    public PageResult<DiscountPromotionDetail> queryPage(DiscountPromotionDetail discountPromotionDetail, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<DiscountPromotionDetail> list = discountPromotionDetailMapper.queryPage(startIndex, pageQuery.getLimit(),discountPromotionDetail);
        long count = discountPromotionDetailMapper.queryPageCount(discountPromotionDetail);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }


}
